/**
 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.library.service.impl;

import java.util.List;

import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.library.model.Publisher;
import com.liferay.library.service.base.PublisherLocalServiceBaseImpl;
import com.liferay.portal.kernel.exception.SystemException;

/**
 * The implementation of the publisher local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.liferay.library.service.PublisherLocalService} interface.
 * </p>
 *
 * <p>
 * Never reference this interface directly. Always use {@link com.liferay.library.service.PublisherLocalServiceUtil} to access the publisher local service.
 * </p>
 *
 * <p>
 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
 * </p>
 *
 * @author Meanson Wang
 * @see com.liferay.library.service.base.PublisherLocalServiceBaseImpl
 * @see com.liferay.library.service.PublisherLocalServiceUtil
 */
public class PublisherLocalServiceImpl extends PublisherLocalServiceBaseImpl {

	/**
	 * Adds the Publisher to the database incrementing the primary key
	 *
	 */
	public Publisher addPublisher(Publisher publisher) throws SystemException {
		long publisherId = CounterLocalServiceUtil.increment(Publisher.class.getName());

		publisher.setPublisherId(publisherId);

		return super.addPublisher(publisher);
	}

	/**
	 * Gets a list with all the Publishers in a group
	 *
	 */
	public List<Publisher> getPublishersByGroupId(long groupId) throws SystemException {
		return publisherPersistence.findByGroupId(groupId);
	}

	/**
	 * Gets a list with a range of Publishers from a group
	 *
	 */
	public List<Publisher> getPublishersByGroupId(long groupId, int start, int end) throws SystemException {
		return publisherPersistence.findByGroupId(groupId, start, end);
	}

	/**
	 * Gets the number of Publishers in a group
	 *
	 */
	public int getPublishersCountByGroupId(long groupId) throws SystemException {
		return publisherPersistence.countByGroupId(groupId);
	}

}